// haxzsAudio Server
// created by omghaxzs
// 2010

#include "main.h"
#include "source.h"
#include "net.h"
#include "dest.h"
#include "window.h"
#include "curses.h"
#include "log.h"
#include "clientwnd.h"
#include "sourcewnd.h"
#include "http.h"
#include "settings.h"

using namespace std;

// Variables
logwnd *l;
clientwnd *clwnd;
sourcewnd *srcwnd;
dest *d;
source *s;
boost::asio::io_service io_service;
settings *setting;

// Prototypes
void createWindows();

// GO
int main (int argc, char *argv[])
{
	// Initialize windows
	window::setup();

	// Create our windows
	createWindows();

	// Initialize settings
	setting = new settings();

	// Initialize network stuff
	net *n;
	n = new net();
	n->initNet();

	d = new dest();	// Initialize our SOURCE listening server
	s = new source(); // Initialize our CLIENT listening server

	s->listenForClients(); // Listen for sources
	d->listenForClients(); // Listen for clients

	return 0;
}

void createWindows()
{
	// Create our logo window
	window *logo = new window(LINES-3, COLS-23, 23, 3);

	// Fill in all the info about it
	logo->color(1);
	logo->centerMsg(0, 0, 23, "haxzs Audio Server ");
	logo->centerMsg(1, 0, 23, "created by omghaxzs");
	logo->centerMsg(2, 0, 23, "2010");
	logo->clrcolor(1);

	// Create our log window
	l = new logwnd(0, 0, COLS, 15);

	// Create our client status window
	clwnd = new clientwnd(LINES-10, 0, 25, 10);

	// Create our source status window
	srcwnd = new sourcewnd(LINES-10, 25, 25, 10);
}